<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新增页面</title>
    <link rel="stylesheet" href="/component/pear/css/pear.css"/>
    <link rel="stylesheet" href="/admin/css/other/console1.css"/>
    <style>
        label.required:after { /* 给红色的必填项打红色星号（文字后）如果打前面用before*/
            content: ' *';
            color: red;
        }

        .layui-form-select dl {
            max-height: 260px;
        }

        .layui-disabled {
            color: black !important;
        }

        .layui-form-item .layui-input-inline {
            width: 400px;
        }
    </style>
</head>
<body class="pear-container" style="">
<form class="layui-form" action="" onsubmit="return false">
    <div class="layui-row layui-col-space10">
        <div class="layui-col-xs12 layui-col-sm12">
            <div class="layui-card">
                <div class="layui-card-body" style="    display: flex;
    flex-direction: column;
    align-items: center;">
                    <div class="layui-form-item">
                        <label class="layui-form-label required">用户部门</label>
                        <div class="layui-input-inline">
                            <div id="demo1" class="xm-select-demo"></div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label required">图纸名称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="fileName" autocomplete="off"
                                   placeholder="请输入文件名称"
                                   class="layui-input">
                        </div>
                    </div>

<!--                    <div class="layui-form-item">-->
<!--                        <label class="layui-form-label required">机柜编号</label>-->
<!--                        <div class="layui-input-inline">-->
<!--                            <select name="cabinetNumber" lay-search lay-filter="cabinetNumber" lay-verify="required"-->
<!--                                    lay-reqtext="机柜编号为必填项" id="cabinetNumber">-->
<!--                                <option value="">请选择机柜</option>-->
<!--                            </select>-->
<!--                        </div>-->
<!--                    </div>-->

<!--                    <div class="layui-form-item">-->
<!--                        <label class="layui-form-label required">箱门</label>-->
<!--                        <div class="layui-input-inline">-->
<!--&lt;!&ndash;                            <select name="boxDoor" lay-filter="boxDoor" id="boxDoor" lay-verify="required">&ndash;&gt;-->
<!--&lt;!&ndash;                                <option value="">请选择箱门编号</option>&ndash;&gt;-->
<!--&lt;!&ndash;                            </select>&ndash;&gt;-->
<!--                            -->
<!--                        </div>-->
<!--                    </div>-->
                </div>
            </div>
        </div>
        <div class="layui-col-xs12 layui-col-sm12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-form-item">
                        <label class="layui-form-label">档案简介</label>
                        <div class="layui-input-block">
                            <textarea name="profile" placeholder="请输入档案简介" class="layui-textarea"
                                      style="min-height: 65px!important;"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="manageSave">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary" id="reset">重置</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>

<script src="/component/layui/layui.js"></script>
<script src="/component/pear/pear.js"></script>
<script src="/xm-select.js"></script>
<script th:inline="javascript">
    var $ = layui.jquery;
    var threeList = [[${threeList}]];
    var demo1 = xmSelect.render({
        el: '#demo1',
        autoRow: true,
        filterable: true,
        tree: {
            //是否显示树状结构
            show: true,
            //是否展示三角图标
            showFolderIcon: true,
            //是否显示虚线
            showLine: true,
            //间距
            indent: 20,
            //默认展开节点的数组, 为 true 时, 展开所有节点
            expandedKeys: false,
        },
        toolbar: {
            show: true,
            list: ['ALL', 'REVERSE', 'CLEAR']
        },
        filterable: true,
        height: 'auto',
        data: function(){
            return threeList;
        }
    })

    layui.use(['form', 'jquery', 'laydate'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let laydate = layui.laydate;
        var util = layui.util;
        var deptId = null;
        //打印
        util.on('lay-on', {
            //打印
            'qrCodePrinting': function () {
                let fileName = $("#fileName").val();
                if (fileName != "") {
                    // 页面层
                    layer.open({
                        title: '二维码生成',
                        type: 2,
                        area: ['400px', '300px'],
                        // offset: ['837px', '105px'],
                        content: '/file/manage/qrCode?fileName=' + fileName,
                        success: function (layero, index, that) {
                        },
                        end: function () {
                        }
                    });
                }
            },
        })


        laydate.render({
            elem: '#selectTime' //指定元素
            , theme: '#393D49',
            type: 'year'
        });
        laydate.render({
            elem: '#entryTime' //指定元素
            , theme: '#393D49',
            type: 'datetime'
        });

        form.on('submit(manageSave)', function (data) {
            let loading = layer.load();
            $.ajax({
                url: '/file/manage/batch/instart/save',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    layer.close(loading);
                    if (result.code == 200) {
                        layer.msg(result.message, {icon: 1, time: 3000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name)); //关闭当前页
                            parent.layui.table.reload("valid");
                        });
                    } else {
                        layer.msg(result.message, {icon: 2, time: 3000});
                    }
                }
            })
            return false;
        });
    })
</script>
<script>
</script>
</body>
</html>
